'use strict';
define(function(require, exports, module) {

    var app = angular.module('myApp', ['ui.router']);

    //初始化应用对象
    require("../common/js/AppInit").init(app);

    var navItems = [{
        "state": "home",
        "label": "主页"
    }, {
        "state": "login",
        "label": "登录",
        "hidden": true
    }, {
        "state": "register",
        "label": "注册",
        "hidden": true
    }, {
        "state": "home.userlog",
        "label": "用户日志",
        "path": "userlog"
    }, {
        "state": "home.syslog",
        "label": "系统日志"
    }];

    app.run(function($rootScope){
        $rootScope.AllNavItems = navItems;
    });


    app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {

        //加载指令
        require("../common/directive/app-header/app-header").init(app); //在头中注册路由
        require("../common/directive/app-footer/app-footer").init(app);

        //加载服务
        require("../common/js/NavService").init(app);

        //加载路由
        var routerHelper = require("../common/js/RouterHelper");
        routerHelper.registerRouteState(app, navItems);

        app.register.urlRouterProvider.when("", "/home");
        app.register.urlRouterProvider.when("/", "/home");
        // app.register.urlRouterProvider.when("/home", "/home/userlog");

    }]);

    //启动应用
    angular.bootstrap(document.body, ['myApp']);

    console.info("app starting...");
});